|
|
|
|
|
|
|
Note The Standard Edition of Visual Basic can't create custom or ActiveX controls directly. However, Microsoft has a standalone Control Creation Edition that you can download from the Microsoft Web site. The steps needed to create an ActiveX control are the same across editions. |
|
|
|
| | If you'll be using the Control Creation Edition, you won't work directly in Visual Basic, but in the special edition of Visual Basic for the Control Creation Edition. Fortunately, the interface of both editions are identical. The Control Creation Edition isn't being used in today's lesson; however, and differences will be noted. |
|
|
|
|
|
Before creating a custom control, you first need to understand what they are, and the different types of custom controls you can create. |
|
|
|
|
|
|
|
|
If you can create a Visual Basic form, you can create an ActiveX control. The steps and skills necessary to create controls are practically identical to those used to create a form. What's more, control creation possibilities are virtually unlimited. |
|
|
|
|
|
|
|
|
Creating custom controls are like teaching an old dog a new trick. Although Visual Basic provides many different controls that you can use, and many other companies produce ActiveX controls to provide particular functionalities, at some point you'll find that you need to perform some task that the existing controls don't perform. |
|
|
|
|
|
|
|
|
For example, if you want users to be able to enter a new value in a combo box, you need to have some code in the combo box's CloseUp routine. That's easy; however, if the new entry requires some additional information to actually add the new value, you need to display another form to get that information. Here's the problem: When the second form is unloaded, the new record is committed to the database with a CommitTrans command. Unfortunately, data controls all use the same workspace, so the data entry that users are working on is also committed. This causes errors when users try to finish the entry and update the database. By creating a custom control that does the initial add and update of the reference information, you aren't unloading a form and can actually code the update process differently, not to mention being able to use this control in other application. |
|
|
|
|
|
|
|
|
Custom controls allow you to create any type of control that you need to solve a unique problem in your application. The only limiting factor is your own imagination. |
|
|
|
|
|